package com.example.questionnaire.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.example.questionnaire.entity.UserAnswererEntity;
import com.example.questionnaire.service.UserAnswererService;
import com.example.common.utils.PageUtils;
import com.example.common.utils.R;



/**
 * 
 *
 * @author hsz
 * @email 1416446590@qq.com
 * @date 2022-10-29 11:20:56
 */
@CrossOrigin
@RestController
@RequestMapping("questionnaire/useranswerer")
public class UserAnswererController {
    @Autowired
    private UserAnswererService userAnswererService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = userAnswererService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		UserAnswererEntity userAnswerer = userAnswererService.getById(id);

        return R.ok().put("userAnswerer", userAnswerer);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody UserAnswererEntity userAnswerer){
		userAnswererService.save(userAnswerer);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody UserAnswererEntity userAnswerer){
		userAnswererService.updateById(userAnswerer);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		userAnswererService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
